/*
	Name:5_1
	Copyright:Take it at will
	Author:Rodney
	Date: 
	Description:
*/
#include<stdio.h>
#include<stdlib.h>

int jg(int num);

int main()
{
    int num,n,mid;
    scanf("%d",&num);
    
    do
    {
        n = jg(num);
        num = n;
    }while(n/10 != 0);
    printf("%d  \n",n);
}

int jg(int num)
{
    int tot=1,index;
    for(;num!=0;num/=10)
    {
        index = num%10;
        if(index != 0)   tot*=index;
    }
    return tot;
}
